package com.hengxinguotong.zhihuichengjian.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/3/27.
 */

public class Structure implements Serializable, Cloneable {
    private String name;
    private String id;
    private boolean isSelected = false;
    private List<Structure> data = new ArrayList<>();

    public List<Structure> getData() {
        return data;
    }

    public void setData(List<Structure> data) {
        this.data = data;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isSelected() {
        return isSelected;
    }

    public void setSelected(boolean selected) {
        isSelected = selected;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        Structure obj = (Structure)super.clone();
        List<Structure> structureList = new ArrayList<Structure>();
        List<Structure> list = getData();
        if (list != null) {
            for (Structure bean : list) {
                Structure b = (Structure)bean.clone();
                structureList.add(b);
            }
            obj.setData(structureList);
        }
        return obj;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Structure) {
            Structure t = (Structure) obj;
            return this.name.equals(t.name) && this.id.equals(t.id);
        }
        return super.equals(obj);
    }
}
